package com.group5.onlinegame.util;

import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ControllerExceptionHandler {
    //这个注解是指当controller中抛出这个指定的异常类的时候，都会转到这个方法中来处理异常
    @ExceptionHandler(AuthorizationException.class)
    //将返回的值转成json格式的数据
    @ResponseBody
    public String handlerUserNotExistException(AuthorizationException ex){
        String result = "权限不足";
        return result;
    }
}
